package hashCodeDemo;

public class Student {
	private String name;
	private int id;
	
	public Student(){}
	public Student(int id, String name){
		this.id = id;
		this.name = name;
	}
	
	public String getName() {
		return name;
	}
	public void setName(String name) {
		this.name = name;
	}
	public int getId() {
		return id;
	}
	public void setId(int id) {
		this.id = id;
	}
	@Override
	public int hashCode(){
		return this.id + this.name.hashCode();
	}
	
	@Override
	public boolean equals(Object obj){
		if(this == obj){
			return true;
		}
		if(obj instanceof Student){
			Student s = (Student) obj;
			if(this.getId() == s.getId() && this.getName().equals(s.getName())){
				return true;
			}else{
				return false;
			}
			
		}else{
			return false;
		}
	}
}
